package com.lee.dutylower.db.greenEntity;

import com.lee.dutylower.db.BaseDB;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import com.lee.dutylower.db.greendao.DaoSession;
import com.lee.dutylower.db.greendao.SoldierDao;
import com.lee.dutylower.db.greendao.TimesDao;
import com.lee.dutylower.db.greendao.SentryDao;
import com.lee.dutylower.db.greendao.PostRecordDao;


/**
 * Created by lijie on 2017/5/17.
 */
@Entity
public class PostRecord extends BaseDB {
    @Id(autoincrement = true)
    private Long recordID;
    @Property
    private Long sentryID;
    @ToOne(joinProperty = "sentryID")
    private Sentry sentry;

    @Property
    private Long timesID;
    @ToOne(joinProperty = "timesID")
    private Times times;

    @Property
    private Long guiderID;
    @ToOne(joinProperty = "guiderID")
    private Soldier soldier;

    @Property
    private Integer dayofweek;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 184446524)
    private transient PostRecordDao myDao;

    @Generated(hash = 878767307)
    public PostRecord(Long recordID, Long sentryID, Long timesID, Long guiderID,
            Integer dayofweek) {
        this.recordID = recordID;
        this.sentryID = sentryID;
        this.timesID = timesID;
        this.guiderID = guiderID;
        this.dayofweek = dayofweek;
    }

    @Generated(hash = 649744793)
    public PostRecord() {
    }

    public Long getRecordID() {
        return this.recordID;
    }

    public void setRecordID(Long recordID) {
        this.recordID = recordID;
    }

    public Long getSentryID() {
        return this.sentryID;
    }

    public void setSentryID(Long sentryID) {
        this.sentryID = sentryID;
    }

    public Long getTimesID() {
        return this.timesID;
    }

    public void setTimesID(Long timesID) {
        this.timesID = timesID;
    }

    public Long getGuiderID() {
        return this.guiderID;
    }

    public void setGuiderID(Long guiderID) {
        this.guiderID = guiderID;
    }

    public Integer getDayofweek() {
        return this.dayofweek;
    }

    public void setDayofweek(Integer dayofweek) {
        this.dayofweek = dayofweek;
    }

    @Generated(hash = 36734472)
    private transient Long sentry__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 288920200)
    public Sentry getSentry() {
        Long __key = this.sentryID;
        if (sentry__resolvedKey == null || !sentry__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SentryDao targetDao = daoSession.getSentryDao();
            Sentry sentryNew = targetDao.load(__key);
            synchronized (this) {
                sentry = sentryNew;
                sentry__resolvedKey = __key;
            }
        }
        return sentry;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 2061760017)
    public void setSentry(Sentry sentry) {
        synchronized (this) {
            this.sentry = sentry;
            sentryID = sentry == null ? null : sentry.getSentry_id();
            sentry__resolvedKey = sentryID;
        }
    }

    @Generated(hash = 1514355700)
    private transient Long times__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1226816115)
    public Times getTimes() {
        Long __key = this.timesID;
        if (times__resolvedKey == null || !times__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            TimesDao targetDao = daoSession.getTimesDao();
            Times timesNew = targetDao.load(__key);
            synchronized (this) {
                times = timesNew;
                times__resolvedKey = __key;
            }
        }
        return times;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 71075949)
    public void setTimes(Times times) {
        synchronized (this) {
            this.times = times;
            timesID = times == null ? null : times.getTimeID();
            times__resolvedKey = timesID;
        }
    }

    @Generated(hash = 718234182)
    private transient Long soldier__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1717579228)
    public Soldier getSoldier() {
        Long __key = this.guiderID;
        if (soldier__resolvedKey == null || !soldier__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SoldierDao targetDao = daoSession.getSoldierDao();
            Soldier soldierNew = targetDao.load(__key);
            synchronized (this) {
                soldier = soldierNew;
                soldier__resolvedKey = __key;
            }
        }
        return soldier;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 725987038)
    public void setSoldier(Soldier soldier) {
        synchronized (this) {
            this.soldier = soldier;
            guiderID = soldier == null ? null : soldier.getSID();
            soldier__resolvedKey = guiderID;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 359305423)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getPostRecordDao() : null;
    }

}
